import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin, loadEnv } from 'electron-vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig(({ mode }) => {
  const { VITE_BASE_API_URL } = loadEnv(mode, process.cwd())
  return {
    main: {
      plugins: [externalizeDepsPlugin()],
      resolve: {
        alias: {
          '@constant': resolve('src/constant')
        }
      }
    },
    preload: {
      plugins: [externalizeDepsPlugin()],
      resolve: {
        alias: {
          '@constant': resolve('src/constant')
        }
      }
    },
    renderer: {
      define: {
        VITE_BASE_API_URL: JSON.stringify(VITE_BASE_API_URL)
      },
      resolve: {
        alias: {
          '@renderer': resolve('src/renderer/src'),
          '@constant': resolve('src/constant')
        }
      },
      plugins: [vue()]
    }
  }
})
